package org.lemon.transport.context.service.queue.discovery;

import lombok.Data;
import org.lemon.transport.context.data.queue.Queue;
import org.lemon.transport.context.data.tenant.TenantId;
import org.server.transport.gen.TransportProto;

@Data
public class QueueRoutingInfo {

    private final TenantId tenantId;
    private final Long queueId;
    private final String queueName;
    private final String queueTopic;
    private final int partitions;

    public QueueRoutingInfo(Queue queue) {
        this.tenantId = queue.getTenantId();
        this.queueId = queue.getId();
        this.queueName = queue.getName();
        this.queueTopic = queue.getTopic();
        this.partitions = queue.getPartitions();
    }

    public QueueRoutingInfo(TransportProto.GetQueueRoutingInfoResponseMsg queue) {
        this.tenantId = TenantId.valueOf(queue.getTenantId());
        this.queueId = queue.getQueueId();
        this.queueName = queue.getQueueName();
        this.queueTopic = queue.getQueueTopic();
        this.partitions = queue.getPartitions();
    }
}
